home *** CD-ROM | disk | FTP | other *** search
/ Digit Magazine 1999 December / cDigit issue 18 - December 1999.iso / pc / demos / GLpro / project.exe / %MAINDIR% / Include / common.GLs < prev    next >
Encoding:
Text File  |  1999-10-05  |  6.7 KB  |  142 lines

  1. ;Script common.txt
  2. ;Last modified by JASON at 22/03/99 10:07:12
  3.  
  4. ;Common.txt
  5. ;Global file which can be used by all parts of the program. Typically contains frequently used routines
  6.  
  7. CreateMenuHotspots: declare intExcept
  8.     ; the declare line allows parameters to be pased into the sub-routine
  9.     ; in this instance we are passing i "intExcept" which will be used later in the routine
  10.         
  11.     ; we are creating a hotspot area for exiting the program
  12.     ; the hotspot is called "menu_exit"
  13.     ; it will call the subroutine "onExit_Click"
  14.     ; the image "bexit" is defining the area to be used (with its offsets and width and height)
  15.     ; the image "bexit" will be used as a push down image
  16.     ; the image "bexitr" will be used as a rollover image
  17.     Hotspot menu_exit gosub onExit_Click bexit bexitr
  18.     
  19.     ;- the mark/loop command is comparable to the FOR NEXT command as seen in basic
  20.     ; i.e. below we are going to loop from 1 to 5
  21.     ; the number of the loop is stored in the variable "@loop"
  22.  
  23.     mark 1 5
  24.         ; --in GLPRO the if- else if - else - endif statement is the same as the BASIC statement
  25.         ; we are checking to see if the value passed in is the same as the "@loop" variable
  26.         If @intExcept==@Loop
  27.             ; the HOTSPOT command defines an active region of the screen to be used
  28.             ; as either a click point roll-over point mouse down inside etc
  29.             ; check-out the command in the help file to understand its versatility
  30.             
  31.             ; we are creating a hotspots with a variable names "menu_button_1" ... "menu_button_5"
  32.             ; using the @loop to append the variable name
  33.             ; the subroutine to be called is "onMenu_Click" and we are passing it the current value of @loop
  34.             ; the coordinates for the hot region are got from the image "mbut_01r" where again the @loop
  35.             ; variable is used to create this name (the pad0 command is just used to format "1" to "01")
  36.             ; this image contains offsets x and y and an x and y size
  37.             ; the image will be displayed when the mouse is pressed over the area and the 
  38.             ; routine called when a click event is triggered (i.e mouse down and mouse up events within the region)
  39.             Hotspot menu_button_$@loop gosub onMenu_Click:(@loop) mbut_$strPAD0(@loop,2)$r
  40.         Else
  41.             ; another hotspot command this time with a rollover image as well so when the mouse goes over
  42.             ; the defines area an image is displayed
  43.             ; for this purpose we are using the click down image for both the rollover and press down
  44.             Hotspot menu_button_$@loop gosub onMenu_Click:(@loop) mbut_$strPAD0(@loop,2)$r mbut_$strPAD0(@loop,2)$r
  45.         EndIf
  46.     endloop
  47.     
  48. RETURN
  49.  
  50. onExit_Click:
  51.     ; EXITNOW exits the GLPRO program
  52.     ; if a shutdown text file exists it will run it
  53.     ; by default the file is called "SHUTDOWN.TXT" but can be changed using "SET SHUTDOWN filename"
  54.     ; the shutdown file in this project can be found in the shutdown directory1
  55.     Exitnow
  56. Return
  57.  
  58. onMenu_Click: declare intMenuButtonID
  59.     ;A menu button has been clicked, if it is a different section than the current one then change
  60.     If @gintCurrentSection<>@intMenuButtonID
  61.         ;different section - clean up and go to new section
  62.         ; calls FREEALL subroutine 
  63.         gosub FreeAll
  64.         ; calls CreateMenuHotspots subroutine  passing it the currently selected option
  65.         gosub CreateMenuHotspots @intMenuButtonID
  66.         ;fade up with fade number "3" the  "menu_button_buffer" image we grabbed in the startup file
  67.         imageFADEAT 3 menu_button_buffer
  68.         ;fade the curently selected section button if "@intMenuButtonID" = 1 then it woulfd be
  69.         ; mbut_01
  70.         imageFADEAT 4 mbut_$strPAD0(@intMenuButtonID,2)
  71.         ; set the value "gintCurrentSection" to the currently selected section
  72.         Global gintCurrentSection @intMenuButtonID
  73.         ; putup (no fade just display) the image "mainmdle"
  74.         imagePUT mainmdle
  75.         ; free this image
  76.         imageFREE mainmdle
  77.         ; this next section links to the file containing the code for the selected section i.e. IMAGES,ANIMATION(ANIM) etc
  78.         if @intMenuButtonID==1
  79.             ; because we are in a subroutine we need to free the stack before we link to another file
  80.             ; POP ALL frees the stack (i.e. no depth)
  81.             POP ALL
  82.             ; LINK images.TXT will pass control to the file IMAGES.TXT all currently merged and active files are 
  83.             ; freed from memory
  84.             ; to enter the images.txt file at a particular point you can specify a lable name i.e. LINK IMAGES.TXT mysub
  85.             scriptLINK IMAGES.GLs
  86.         else if @intMenuButtonID==2
  87.             POP ALL
  88.             scriptLINK ANIM.GLs
  89.         else if @intMenuButtonID==3
  90.             POP ALL
  91.             scriptLINK SOUNDV.GLs
  92.         else if @intMenuButtonID==4
  93.             POP ALL
  94.             scriptLINK HOTSPOT.GLs
  95.         else if @intMenuButtonID==5
  96.             POP ALL
  97.             scriptLINK LAYERS.GLs
  98.         endif
  99.     endIf
  100. RETURN
  101.  
  102. FreeAll:
  103.     ;Free all possible whens, avi files, layers, clippings & images, hotspots, animations
  104.     ;variables, and sounds - basically a clean up operation.
  105.     
  106.     ; - imageSET returns the drawing buffer to the on screen buffer as aposed to any buffers defined within the code
  107.     imageSET
  108.     ; - the drawREGION command by itself returns the drawing region of the screen to the full buffer
  109.     drawREGION
  110.     ; fontSHADOW 0 removes any previously defines font styles
  111.     fontSHADOW 0
  112.     ;- whenFREE is used to free when events - "whn*" will free all defines whens that start with "whn"
  113.     whenFREE "whn*"
  114.     ;---- this mci call closes all mci tasks currently being executed by GLPRO
  115.     mci "close all"
  116.     ;- layerFREE is used to free defined layers matching the given criteria "lyr*"
  117.     layerFREE "lyr*"
  118.     ; imageFREE is used to free clippings/images held in memory, For any free line the variables to be freed can be cascaded as below
  119.     imageFREE "buf*" "snd*"  "volup" "voldn" "playin" "forward" "rewind"
  120.     imageFREE "roll" "down" "click" "star"
  121.     ; hotFREE frees defines hotspots matching the given criteria "hot*"
  122.     hotFREE "hot*"
  123.     ; animFREE frees animations loaded in memory matching the given criteria "anim*"
  124.     animFREE "anm*"
  125.     ; varFREE is used to free variables
  126.     varFREE "gintCurveX" "gintCurveY" "gintShipXoffset" "gintShipYoffset"
  127.     varFREE "gintSoundName*" "gintSoundLoop*" "gintSoundVolume" "gintBalanceShare"
  128.     ; soundFREE is used to free sound files
  129.     soundFREE "snd*"
  130.     
  131.     ; the command "FREE"can also be used. FREE is not type specific so for example if you FREE "hot*" 
  132.     ; GLPRO will free all images, animations, variables, whens, hotspots, sound files etc that are defined 
  133.     ; meeting ther criteria "hot*"
  134.     
  135.     ; memory management is a very big part of GLPRO and optimising the speed of any presentation depend
  136.     ; greatly on what is kept loaded in memory (i.e. will be used alot) and what is used and freed.
  137.     
  138.     ; The GLPRO engine itself occupies a lot less than 1MB of memory so there is a lot left there to play with
  139.     ; most GLPRO applications occupy 1.2MB - 2.5MB of memory depending on how you optimise your code. 
  140.  
  141. Return
  142.